﻿namespace NodeBasedSkillEditor.Model.Node.RT
{
    public class Node_Add_RT : RT_Node
    {
        public RT_SingleValuePort[] In_Adds;

        public RT_SingleValuePort Out_Sum;

        public Node_Add_RT(Node_Add sourceData, RT_DAG parentDag) : base(sourceData, parentDag)
        {
            In_Adds = BuildRTPortArrayFromGroup<RT_SingleValuePort>(EPortIOType.Input, sourceData.Add);

            Out_Sum = new RT_SingleValuePort(EPortIOType.Output, sourceData.Sum, this);
            Out_Sum.OnGetValue = GetSum;
        }

        public AValue GetSum(DAG_Executor executor)
        {
            Out_Sum.SourceValue.Reset();
            foreach (var a in In_Adds)
            {
                Out_Sum.SourceValue.Add(a.GetValue(executor));
            }
            return Out_Sum.SourceValue;
        }
    }
}
